package com.lty.jeeg.server.modules.fas.dao;

import java.util.List;
import java.util.Map;

import com.lty.jeeg.server.modules.fas.dto.SupplierDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import org.springframework.stereotype.Repository;

import com.lty.jeeg.server.modules.fas.model.Supplier;

/**
 * @author : LTY
 * @date : 2019-02-12 10:01:41
 * Description : 供应商
 */
@Mapper
@Repository
public interface SupplierDao {

    /**
     * 根据ID获取
     * @param id ID
     * @return bean
     */
    SupplierDTO getById(Long id);

    /**
     * 删除
     * @param id ID
     * @return 1/0
     */
    @Delete("update fas_supplier set isDeleted = '1' where id = #{id}")
    int delete(Long id);

    /**
     * 修改
     * @param supplier ID
     * @return 1/0
     */
    int update(Supplier supplier);

    /**
     * 保存
     * @param supplier bean
     * @return ID
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into fas_supplier(name, contact, phone, address, usable, remark, createBy, updateBy, isDeleted) values(#{name}, #{contact}, #{phone}, #{address}, #{usable}, #{remark}, #{createBy}, #{updateBy}, #{isDeleted})")
    Long save(Supplier supplier);

    /**
     * 计数
     * @param params 筛选条件
     * @return 总数
     */
    int count(@Param("params") Map<String, Object> params);

    /**
     * 列表
     * @param params 筛选条件
     * @param offset 页码
     * @param limit 分页数目
     * @return beanList
     */
    List<Supplier> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    /**
     * 列表
     * @param params 筛选条件
     * @param offset 页码
     * @param limit 分页数目
     * @return beanList
     */
    List<Supplier> query(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
